<template>
	<joy-page class="">
		<view class="body">
			<view class="top">
				<view class="space-between">
					<view style="display: flex;align-items: center;">
						<text class="post">{{position.jobName}}</text>
						<view class="t1">急聘</view>
					</view>
					
					
					<text class="salary">{{position.salaryRang}}</text>
				</view>
				
				<view class="require">
					<view class="item" >
						<!-- <text class="yzb yzb-location top-icon"></text> -->
						<image class="tub" src="https://i-7xvfsljtcgf3cswfwvr8oss.oss-cn-shenzhen.aliyuncs.com/image/2.png" style="width: 25upx;height: 29upx;" ></image>
						<text>{{position.jobAddress}}</text>
					</view>
					<view class="item">
						<!-- <text class="yzb yzb-gongzuobao top-icon"></text> -->
						<image class="tub" src="https://i-7xvfsljtcgf3cswfwvr8oss.oss-cn-shenzhen.aliyuncs.com/image/3.png" ></image>
						<text>{{position.requestExperience}}</text>
					</view>
					<view class="item">
						<!-- <text class="yzb yzb-xueli top-icon"></text> -->
						<image class="tub" src="https://i-7xvfsljtcgf3cswfwvr8oss.oss-cn-shenzhen.aliyuncs.com/image/4.png" ></image>
						<text>{{position.requestEducation}}</text>
					</view>
				</view>
			</view>
			<view class="user space-between">
				<view class="left">
					<image style="width: 100upx;height:100upx;border-radius: 20%;" src="https://i-7xvfsljtcgf3cswfwvr8oss.oss-cn-shenzhen.aliyuncs.com/image/19.png"></image>
					<view class="info">
						<view class="name">
							<text class="user-name">陈女士</text>
							<text class="last-status">刚刚活跃</text>
						</view>
						<text class="position">{{position.enterprise.enterpriseName}}</text>
					</view>
				</view>
				<text class="yzb yzb-next icon-next"></text>
			</view>
			<view class="detail">
				<view class="t10">
					<text class="title">职位详情</text>
					<view class="t11">
						<image src="https://i-7xvfsljtcgf3cswfwvr8oss.oss-cn-shenzhen.aliyuncs.com/image/5.png"></image>
						<image style="width: 44upx;height: 44upx;" src="https://i-7xvfsljtcgf3cswfwvr8oss.oss-cn-shenzhen.aliyuncs.com/image/6.png"></image>
						<image src="https://i-7xvfsljtcgf3cswfwvr8oss.oss-cn-shenzhen.aliyuncs.com/image/7.png"></image>
					</view>	
				</view>	
				
				<view class="skill">
					<text>ps</text>
					<text>设计</text>
				</view>
				<view class="desc mar-top-15">
					{{position.jobDescription}}
				</view>				
			</view>

			<view class="company">
				<!-- <view class="company-info space-between" @click="toCompany()"> -->
		
				<view class="company-info space-between" @click="tz(position.enterpriseId)">
					<view class="left">
						<image style="width: 60upx;height: 60upx;" src="https://i-7xvfsljtcgf3cswfwvr8oss.oss-cn-shenzhen.aliyuncs.com/image/19.png"></image>
						<view class="info">
							<view class="name"><text class="user-name">xxx</text></view>
							<text class="position">XXX公司 · CEO</text>
						</view>
					</view>
					<text class="yzb yzb-next icon-next"></text>
				</view>
				<!-- <view class="company-location"><map></map></view> -->
			</view>
			<view class="warn">
				<view class="top">
					<!-- <text class="yzb yzb-anquan icon-warn"></text> -->
					<text class="title">需求直聘安全提示：</text>
				</view>
				<view class="bottom">
					<text style="color: #666666;">需求直聘严禁用人单位做出任何损害求职者合法权益的违法违规行为，包括但不限于扣押求职者证件、收取求职者财物、向求职者集资、让求职者入股、诱导求职者异地入职、异地参与培训等，您—旦发现此类行为。</text>
					<text class="report">请立即举报</text>
					<view class="t3">了解更多职场安全防范知识></view>
				</view>
			</view>
		<!-- 	<view class="others">
				<text class="title">该公司其他岗位</text>
				<m-position :positions="positionList" @click="positionDetail"></m-position>
				<view class="load-more-box">
					<uni-load-more v-if="status == '请求中'" status="正在加载..." :showIcon="true"></uni-load-more>
					<uni-load-more v-if="status == '没有更多'" status="没有更多了" :showIcon="false"></uni-load-more>
					<uni-load-more v-if="status == '暂无数据'" status="暂无数据" :showIcon="false"></uni-load-more>
					<uni-load-more v-if="status == '请求失败'" status="加载失败，点我重试" :showIcon="false" @click="reLoad"></uni-load-more>
				</view>
			</view> -->
			
		</view>
		<view style="height: 150upx;"></view>	
		<view class="but">
			<view class="gt" @click="toMessage(position)">立即沟通</view>
		</view>	
	</joy-page>
</template>

<script>
import { mapState, mapGetters } from 'vuex';
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
export default {
	components: {uniLoadMore},
	computed: {
		...mapState(['forcedLogin']),
		...mapGetters(['hasLogin'])
	},
	data() {
		return {
			banner: [],
			grid: [],
			ka: [],
			adList: [],
			position:{},
			query: {
				limit: 10,
				page: 1,
				id:null,
			},
			positionList:[],
			status: '',
		};
	},
	async onLoad(query) {
		console.log(uni.getStorageSync("isUser"),'---求职者')
		if(query.id){
			this.getDetail(query.id);
		}
	},
	onReachBottom() {
		this.query.page++;
		// this.getPositionList();
	},
	methods: {
		tz(id){
		
			uni.navigateTo({
					url:"/pages/index/companydetails?id="+id,
					
			})
		},
		/* 跳转消息页 */
		toMessage(item){
			console.log("chat item",item);
			var isUser=uni.getStorageSync("isUser") ||1
			// uni.navigateTo({
			// 	url:'/pages/chat/chat_detail'
			// })
			uni.navigateTo({
				url:'/pages/chat/chat_detail?conversationID='  +(isUser==1? 'C2CSQZPB-AA':'C2CSQZPC-AA')+item.enterprise.enterpriseApplyWxUserId  + "&userID=" +(isUser==1? 'SQZPB-AA':'SQZPC-AA')+item.enterprise.enterpriseApplyWxUserId,
			})
		},
		/**
		 * 查询职位详情
		 */
		async getDetail(id){
			let data = await this.$apis.detailEnterprise_job(id);
			console.log('data', data)
			if(data && data.code === 200){
				// if(data.skill){
				// 	data.skill=data.skill.split(",");
				// }
				this.position=data.data;
				// this.getPositionList();
			}
		},
		
		async getPositionList() {
			this.query.id=this.position.id;
			this.status = '请求中';
			let res = await this.$apis.getCompanyPositionList(this.query);
			if (res) {
				let data = res.data;
				for (let i in data) {
					if (data[i].skill) {
						data[i].skill = data[i].skill.split(',');
					}
				}
				this.positionList = this.positionList.concat(data || []);
				this.changeStatus(res);
			}
		},
		
		// 修改请求状态
		changeStatus(data) {
			if (this.positionList.length === 0) {
				this.status = '暂无数据';
			} else if (this.page >= Math.ceil(data.count / this.limit)) {
				this.status = '没有更多';
			} else {
				this.status = '请求更多';
			}
		},
		
		
		
		toCompany(){
			this.$mRouter.push({
				route: this.$mRoutesConfig.companyDetail,
				query: {
					id: this.position.companyId
				}
			});
		},
		
		positionDetail(item) {
			this.$mRouter.push({
				route: this.$mRoutesConfig.positionDetail,
				query: {
					id: item.id
				}
			});
		}
		
	}
};
</script>

<style lang="scss" scoped>
	.t1{
		width:  80upx;
		height: 44upx;
		background: #FFF1F0;
		border-radius: 4upx;
		opacity: 1;
		border: 2upx solid #FFA39E;
		font-weight: 500;
		color: #DC6667;
		line-height: 44upx;
		font-size: 24upx;
		text-align: center;
		margin-left: 46upx;
		font-family: Source Han Sans SC-Medium, Source Han Sans SC;
	}
.space-between {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.center-align {
	display: flex;
	align-items: center;
}

.body {
	padding: 20upx;
	box-sizing: border-box;
	background-color: $bgcolor_white;
}

.top {
	padding: 30upx 0;
	.post {
		font-size: $font-size-40;
		font-weight: bold;
		color: $font-color-000;
	}
	.salary {
		font-size: $font-size-34;
		font-weight: bold;
		color: $main-color;
	}
	.require {
		display: flex;
		flex-direction: row;
		margin-top: 15upx;
		.item {
			margin-right: 30upx;
			display: flex;
			align-items: center;
			text{
				font-size: 28upx;
				font-family: Source Han Sans SC-Regular, Source Han Sans SC;
				font-weight: 400;
				color: #323233;
			}
			.tub{
				width: 32upx;
				height: 32upx;
				margin-right: 12upx;
			}
		}
		.top-icon {
			font-size: $font-lg;
			margin-right: 10upx;
		}
	}
}

.user {
	padding: 35upx 0;
	border-top: 1upx solid $border-color-base;
	border-bottom: 1upx solid $border-color-base;
	.left {
		display: flex;
		flex-direction: row;
		align-items: center;
		.info {
			margin-left: 30upx;
			display: flex;
			flex-direction: column;
			.name {
				display: flex;
				align-items: baseline;
				.user-name {
					font-size: $uni-font-size-lg;
					font-weight: bold;
				}
				.last-status {
					margin-left: 10upx;
					font-size: $uni-font-size-sm;
					color: $font-color-999;
				}
			}
			.position {
				font-size: $uni-font-size-base;
				margin-top: 15upx;
				color: $font-color-666;
			}
		}
	}
	image {
		width: 80upx;
		height: 80upx;
	}
	.icon-next {
		color: $font-color-666;
		font-size: $uni-font-size-lg;
	}
}

.detail {
	display: flex;
	flex-direction: column;
	padding-bottom: 40upx;
	.t10{
		display: flex;
		justify-content: space-between;
		.t11{
			display: flex;
			align-items: center;
			padding: 40upx 0;
			image{
				width: 38upx;
				height: 32upx;
				margin-right: 34upx;
			}
		}
		.title {
			font-size: $uni-font-size-lg;
			font-weight: bold;
			padding: 40upx 0;
		}
	}
	
	.desc {
		line-height: 1.8;
	}
	.skill {
		margin-top: 25upx;
		flex-wrap: wrap;
		text {
			font-size: $uni-font-size-base;
			padding: 10upx 20upx;
			margin-right: 15upx;
			background-color: $border-color-base;
			border-radius: 5upx;
			color: $font-color-666;
		}
	}
}

.company {
	display: flex;
	flex-direction: column;
	padding: 35upx 0;
	border-top: 1upx solid $border-color-base;
	border-bottom: 1upx solid $border-color-base;
	.company-info {
		padding: 0 0 35upx 0;
		// border-top: 1upx solid $border-color-base;
		// border-bottom: 1upx solid $border-color-base;
		.left {
			display: flex;
			flex-direction: row;
			align-items: center;
			.info {
				margin-left: 30upx;
				display: flex;
				flex-direction: column;
				.name {
					display: flex;
					align-items: baseline;
					.user-name {
						font-size: $uni-font-size-lg;
					}
					.last-status {
						margin-left: 10upx;
						font-size: $uni-font-size-sm;
						color: $font-color-999;
					}
				}
				.position {
					font-size: $uni-font-size-base;
					margin-top: 15upx;
					color: $font-color-666;
				}
			}
		}
		image {
			width: 120upx;
			height: 120upx;
		}
		.icon-next {
			color: $font-color-666;
			font-size: $uni-font-size-lg;
		}
	}
}

.warn{
	padding: 10upx 0 40upx 0;
	border-bottom: 1upx solid $border-color-base;
	.top{
		display: flex;
		flex-direction: row;
		align-items: center;
		.icon-warn{
			color: $main-color;
		}
		.title{
			margin-left: 10upx;
			font-size: $uni-font-size-lg;
			font-weight: bold;
			color: #666666;
		}
	}
	
	.bottom{
		font-size: $uni-font-size-base;
		.t3{
			color: #666666;
			font-size: 26upx;
			font-family: Source Han Sans SC-Regular, Source Han Sans SC;
			font-weight: 400;
			margin-top: 20upx;
			
		}
	}
	.report{
		color: #459AE4;
		
	}
}

.others{
	display: flex;
	flex-direction: column;
	.title{
		font-size: $font-size-36;
		font-weight: bold;
		padding: 20upx;
	}
	
}
.but{
	width: 750upx;
	height: 144upx;
	background: #FFFFFF;
	box-shadow: 0px 2px 12px 2px rgba(0,0,0,0.1608);
	border-radius: 0px 0px 0px 0px;
	opacity: 1;
	position: fixed;
	bottom: 0;
	.gt{
		width: 592upx;
		height: 88upx;
		margin: 0 auto;
		background: #84C0F4;
		border-radius: 8upx;
		opacity: 1;
		font-size: 30upx;
		font-weight: 700;
		color: #FFFFFF;
		line-height: 88upx;
		font-family: Source Han Sans SC-Medium, Source Han Sans SC;
		text-align: center;
		margin-top: 22upx;
		
	}
}

</style>
